package xerrors

import "gitee.com/liuxuezhan/ar-platform/base-common/pkg/xcode"

// * 所有业务错误码为 10 位 int64 数字
// * [1,3] 为业务组
// * [4] 位 0表示API层 1表示RPC层
// * [5,10]位表示对应业务错误码，由业务组自行分配
var (
	Successful           = xcode.New(200, "Successful")
	SettingRpcSuccessful = xcode.New(200, "Successful")
	BusinessFailure      = xcode.New(10001, "BusinessFailure")
	NotData              = xcode.New(10002, "not data")
	ParamsInvalid        = xcode.New(20000, "Invalid parameters")
	MerchantIdEmpty      = xcode.New(20001, "Merchant ID cannot be empty")
	AgreementTypeInvalid = xcode.New(20002, "Invalid protocol type")
	NotLogin             = xcode.New(20003, "not login")

	ErrHeadLogin           = 10000000
	RegisterParameterError = xcode.NewRpc(ErrHeadLogin+10001, "Please enter your password")
	RegisterTypeError      = xcode.NewRpc(ErrHeadLogin+10002, "RegisterType is required")
	InviteCodeError        = xcode.NewRpc(ErrHeadLogin+10003, "Please enter the invitation code")
	UserError              = xcode.NewRpc(ErrHeadLogin+10004, "user already exist")
	DBMsgError             = xcode.NewRpc(ErrHeadLogin+10005, "DBError")

	ErrHead                          = 61000000
	ErrUserNotExist                  = xcode.NewRpc(ErrHead+500001, "User not exist.")
	ErrWalletLogTypeNotExist         = xcode.NewRpc(ErrHead+500101, "The wallet log type does not exist.")
	ErrWalletLogTransferTypeNotExist = xcode.NewRpc(ErrHead+500102, "The wallet log transfer type does not exist.")
	ErrWalletBalanceAddFailed        = xcode.NewRpc(ErrHead+500201, "Wallet balance addition failed.")
	ErrWalletBalanceInsufficient     = xcode.NewRpc(ErrHead+500202, "Insufficient wallet balance.")
	ErrWalletValidConsumeAddFailed   = xcode.NewRpc(ErrHead+500211, "Wallet valid consume addition failed.")
	ErrWalletValidMarkAddFailed      = xcode.NewRpc(ErrHead+500212, "Wallet valid mark addition failed.")
	ErrWalletBalanceNotEnough        = xcode.NewRpc(ErrHead+500213, "Balance not enough.")
	ErrInvalidParameterAmount        = xcode.NewRpc(ErrHead+500301, "Invalid parameter amount.")
	ErrInvalidParameterValidMark     = xcode.NewRpc(ErrHead+500302, "Invalid parameter validMark.")
	ErrInvalidParameterValidConsume  = xcode.NewRpc(ErrHead+500303, "Invalid parameter validConsume.")
	ErrInvalidParameterUserIds       = xcode.NewRpc(ErrHead+500304, "Invalid parameter userIds.")
	ErrPleaseConfigInoutType         = xcode.NewRpc(ErrHead+500305, "Please config inout type.")
	ErrUserWashNotOpened             = xcode.NewRpc(ErrHead+500401, "User wash not opened.")

	ErrWithDrawAmountNOTENOUGH      = xcode.NewRpc(ErrHead+600001, "amount not enough.")
	ErrWithDrawUserWalletNotSave    = xcode.NewRpc(ErrHead+600002, "UserWallet not save.")
	ErrWithDrawOrderNot             = xcode.NewRpc(ErrHead+600003, "WithDrawOrder not.")
	ErrWithDrawOrderNotSave         = xcode.NewRpc(ErrHead+600004, "WithDrawOrder not save.")
	ErrWithDrawUserWalletLogNotSave = xcode.NewRpc(ErrHead+600005, "UserWalletLog not save.")
	ErrBankAgentNotAdd              = xcode.NewRpc(ErrHead+600006, "ErrBankAgentNotAdd.")
	ErrUserChannelPixNot            = xcode.NewRpc(ErrHead+600007, "ErrUserChannelPixNot.")
	ErrUserChannelUsdtNot           = xcode.NewRpc(ErrHead+600008, "ErrUserChannelUsdtNot.")
	ErrUserChannelEwalletNot        = xcode.NewRpc(ErrHead+600009, "ErrUserChannelEwalletNot.")
	ErrUserChannelLocalEwalletNot   = xcode.NewRpc(ErrHead+6000010, "ErrUserChannelLocalEwalletNot.")
	ErrUserChannelBankNot           = xcode.NewRpc(ErrHead+6000011, "ErrUserChannelBankNot.")
	ErrWithDrawChannelNot           = xcode.NewRpc(ErrHead+6000012, "Err WithDraw Channel Not")
	ErrConsumeMustGreaterEqualMark  = xcode.NewRpc(ErrHead+6000013, "Consume Must Greater Equal Mark")
	ErrUserChannelNot               = xcode.NewRpc(ErrHead+6000014, "ErrUserChannelNot.")
	ErrUserWithdrawTimeCanNot       = xcode.NewRpc(ErrHead+6000015, "ErrUserWithdrawTimeCanNot.")
	ErrUserWithdrawDailyTimesCanNot = xcode.NewRpc(ErrHead+6000016, "ErrUserWithdrawDailyTimesCanNot.")
	ErrWithdrawFeeErr               = xcode.NewRpc(ErrHead+6000017, "ErrWithdrawFeeErr.")
	ErrRateCANTNUll                 = xcode.NewRpc(ErrHead+6000018, "ErrRateCANTNUll.")

	ErrRechargeOrderNotExist  = xcode.NewRpc(ErrHead+700007, "Recharge order does not exist.")
	ErrRechargeOrderProcessed = xcode.NewRpc(ErrHead+700007, "Recharge order has been processed.")

	ErrDataConvert    = xcode.New(ErrHead+700001, "Failed converting data")
	ErrDuplicatedKey  = xcode.New(ErrHead+700002, "Duplicated key")
	ErrInsert         = xcode.New(ErrHead+700003, "Error inserting data")
	ErrNoRows         = xcode.New(ErrHead+700004, "Record not found")
	ErrUpdate         = xcode.New(ErrHead+700005, "Failed saving data")
	ErrNoRowsAffected = xcode.New(ErrHead+700006, "No rows affected")
	ErrDel            = xcode.NewRpc(ErrHead+700007, "Failed to delete data")
)

var (
	ParameterError int32 = 70001
	DBError        int32 = 71001
	DataError      int32 = 72001
)

func New(err error) error {
	return xcode.NewRpc(ErrHead+799999, err.Error())
}
